/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.web.servlet;

import com.web.daoimpl.StudentDaoImpl;
import com.web.entity.Student;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author liqianru
 */
@WebServlet("/operateStu")
public class Admin_operateStu extends HttpServlet {

    StudentDaoImpl service = new StudentDaoImpl();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //
        String sid = req.getParameter("sid");
        String sname = req.getParameter("sname");
        String spwd = req.getParameter("spwd");
        String sgender = req.getParameter("sgender");
        String classid = req.getParameter("classid");


            Student student = new Student(sid, sname, spwd, sgender, classid);
            System.out.println(student.getSname() + " " + student.getSid());
            //
            int rows = service.insertNewStudent(student);
            if (rows > 0) {
                System.out.println(rows);
                resp.getWriter().print(student);
            } else {
                resp.getWriter().print("error");
            }
        


    }

}
